package com.cskaoyan.controller.lzp_controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Issue;
import com.cskaoyan.bean.lzp.IssueAnswerBO;
import com.cskaoyan.bean.lzp.IssueData;

import com.cskaoyan.bean.params.BaseParam;

import com.cskaoyan.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * \* Description:
 * \* @author: Lizhanpeng
 * \* Date: 2022/5/6
 * \
 */
@RestController
@RequestMapping("admin/issue")
public class IssueController {
    @Autowired
    IssueService issueService;

    @GetMapping("list")
    public BaseRespVo issueList(String question, BaseParam param){
     IssueData questionData = issueService.query(param,question);
      return BaseRespVo.ok(questionData);
    }

    @PostMapping("create")
    public BaseRespVo issueCreate(@RequestBody IssueAnswerBO issueAnswer){
        Issue issue = issueService.create(issueAnswer.getQuestion(),issueAnswer.getAnswer());
        return BaseRespVo.ok(issue);
    }

    @PostMapping("delete")
    public BaseRespVo issueDelete(@RequestBody Issue issue){
        int i =  issueService.delete(issue);
        return BaseRespVo.listOk(null);
    }

    @PostMapping("update")
    public BaseRespVo issueUpdate(@RequestBody Issue issue){
        Issue issue1= issueService.update(issue);
        return BaseRespVo.listOk(issue1);
    }



}
